package com.ruoyi.game.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.game.domain.GameSet;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.game.service.IGameSetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 对局(一局)Controller
 * 
 * @author ruoyi
 * @date 2025-04-18
 */
@RestController
@RequestMapping("/game/set")
public class GameSetController extends BaseController
{
    @Autowired
    private IGameSetService gameSetService;

    /**
     * 查询对局(一局)列表
     */
    // @PreAuthorize("@ss.hasPermi('game:set:list')")
    @GetMapping("/list")
    public TableDataInfo list(GameSet gameSet)
    {
        startPage();
        List<GameSet> list = gameSetService.selectGameSetList(gameSet);
        return getDataTable(list);
    }

    /**
     * 导出对局(一局)列表
     */
    // @PreAuthorize("@ss.hasPermi('game:set:export')")
    @Log(title = "对局(一局)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GameSet gameSet)
    {
        List<GameSet> list = gameSetService.selectGameSetList(gameSet);
        ExcelUtil<GameSet> util = new ExcelUtil<GameSet>(GameSet.class);
        util.exportExcel(response, list, "对局(一局)数据");
    }

    /**
     * 获取对局(一局)详细信息
     */
    // @PreAuthorize("@ss.hasPermi('game:set:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gameSetService.selectGameSetById(id));
    }

    /**
     * 新增对局(一局)
     */
    // @PreAuthorize("@ss.hasPermi('game:set:add')")
    @Log(title = "对局(一局)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GameSet gameSet)
    {
        return toAjax(gameSetService.insertGameSet(gameSet));
    }

    /**
     * 修改对局(一局)
     */
    // @PreAuthorize("@ss.hasPermi('game:set:edit')")
    @Log(title = "对局(一局)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GameSet gameSet)
    {
        return toAjax(gameSetService.updateGameSet(gameSet));
    }

    /**
     * 删除对局(一局)
     */
    // @PreAuthorize("@ss.hasPermi('game:set:remove')")
    @Log(title = "对局(一局)", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gameSetService.deleteGameSetByIds(ids));
    }
}
